import IPairTxData from '~/models/IData'
import IPlugin from './IPlugin'
import moment from 'moment'

export default class TimeDisplayPlugin implements IPlugin {

    name =  'TimeDisplay'

    async modData(data: IPairTxData) {
        const mints = data.mints
        const burns = data.burns
        const swaps = data.swaps

        for (let i = 0; i < mints.length; i++) {
            mints[i].time = moment(mints[i].transaction.timestamp * 1000).fromNow();
        }
        for (let i = 0; i < burns.length; i++) {
            burns[i].time = moment(burns[i].transaction.timestamp * 1000).fromNow();
        }
        for (let i = 0; i < swaps.length; i++) {
            swaps[i].time = moment(swaps[i].transaction.timestamp * 1000).fromNow();
        }
        return data
    }
}